package com.lykj.modules.shop.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.lykj.modules.shop.entity.StoreProduct;
import com.lykj.modules.shop.excel.StoreProductExcel;
import com.lykj.modules.shop.vo.StoreProductVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * 平台商品表 Mapper 接口
 *
 * @author cxl
 * @since 2022-01-13
 */
public interface StoreProductMapper extends BaseMapper<StoreProduct> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param storeProduct
	 * @return
	 */
	List<StoreProductVO> selectStoreProductPage(IPage page, StoreProductVO storeProduct);

	/**
	 * 导出区划数据
	 *
	 * @param queryWrapper
	 * @return
	 */
	List<StoreProductExcel> export(@Param("ew") Wrapper<StoreProduct> queryWrapper);

	@Update("update `shsy_store_product` set sales_volume = sales_volume+#{count},reserve_count = reserve_count-#{count} where id = #{id} and reserve_count > 0")
	int updateReserveAndSales(@Param("id") Long id, @Param("count") int count);
}
